<!--{template /module/admin/view/head}-->
<div id="left_layout">
	<div id="main_content" class="container-fluid">
		<!--{template /module/admin/view/head_nav}-->
		<div class="row-fluid">
			<form method="post" action="{$ADMIN_SCRIPT}/cms/subject/{$dispatches[method]}&id={$_var[gp_id]}&page={$_var[page]}&psize={$_var[psize]}&ref={$_var[gp_ref]}{$search[querystring]}" onsubmit="javascript:return check_form(this);">
				<input type="hidden" name="formsubmit" value="yes" />
				<div class="well widget">
					<div class="widget-header">
						<p class="text">* {lang admin.validate.require}</p>
					</div>
					<div class="widget-content">
						<fieldset>
							<label>{lang cms.subject_edit.view.identity.label} *</label>
							<input type="text" class="input-xlarge" name="txtIdentity" placeholder="{lang cms.subject_edit.view.identity.placeholder}" maxlength="50" value="{$subject[IDENTITY]}" /> 
							<span class="help-inline">{lang cms.subject_edit.view.identity.tips}</span>
							
							<label>{lang cms.subject_edit.view.title.label} *</label>
							<input type="text" class="input-xlarge" name="txtTitle" placeholder="{lang cms.subject_edit.view.title.placeholder}" maxlength="50" value="{$subject[TITLE]}" /> 
							<span class="help-inline">{lang cms.subject_edit.view.title.tips}</span>
							
							<label>{lang cms.subject_edit.view.expried.label}</label>
							<input type="text" class="input-medium input-time" name="txtExpried" value="{$subject[EXPRIED]}" /> 
							<span class="help-inline">{lang cms.subject_edit.view.expried.tips}</span>
							
							<label>{lang cms.subject_edit.view.subtitle.label}</label>
							<input type="text" name="txtSubTitle1" maxlength="50" class="input-xlarge" value="{$subject[SUBTITLE1]}" />&nbsp;
							<input type="text" name="txtSubTitle2" maxlength="50" class="input-xlarge" value="{$subject[SUBTITLE2]}" />&nbsp;
							<input type="text" name="txtSubTitle3" maxlength="50" class="input-xlarge" value="{$subject[SUBTITLE3]}" /> 
							<span class="help-inline">{lang cms.subject_edit.view.subtitle.tips}</span>
							
							<label>{lang cms.subject_edit.view.address.label}</label>
							<input type="text" name="txtAddress" maxlength="100" class="input-xlarge" value="{$subject[ADDRESS]}" />
							<span class="help-inline">{lang cms.subject_edit.view.address.tips}</span>
							
							<label>{lang cms.subject_edit.view.summary.label}</label>
							<textarea class="span6" rows="3" name="txtSummary">{$subject[SUMMARY]}</textarea>
							<span class="help-inline">{lang cms.subject_edit.view.summary.tips}</span>
							
							<label>{lang cms.subject_edit.view.content.label}</label>
							<textarea name="txtContent" id="txt_content" rows="10" class="span8" style="width:100%; height:300px;">{$subject[CONTENT]}</textarea>
							<span class="help-inline">{lang cms.subject_edit.view.content.tips}</span>
							
							<hr/>
							<label>{lang cms.subject_edit.view.iscommend.label}</label>
							<select name="eleIsCommend">
						        <option value="0">{lang cms.subject_edit.view.iscommend.option.0}</option>
						        <option value="10" {if $subject['ISCOMMEND'] == 10}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.10}</option>
						        <option value="9" {if $subject['ISCOMMEND'] == 9}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.9}</option>
						        <option value="8" {if $subject['ISCOMMEND'] == 8}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.8}</option>
						        <option value="7" {if $subject['ISCOMMEND'] == 7}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.7}</option>
						        <option value="6" {if $subject['ISCOMMEND'] == 6}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.6}</option>
						        <option value="5" {if $subject['ISCOMMEND'] == 5}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.5}</option>
						        <option value="4" {if $subject['ISCOMMEND'] == 4}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.4}</option>
						        <option value="3" {if $subject['ISCOMMEND'] == 3}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.3}</option>
						        <option value="2" {if $subject['ISCOMMEND'] == 2}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.2}</option>
						        <option value="1" {if $subject['ISCOMMEND'] == 1}selected="selected"{/if}>{lang cms.subject_edit.view.iscommend.option.1}</option>
					        </select>
							<span class="help-inline">{lang cms.subject_edit.view.iscommend.tips}</span>
							
							<label>{lang cms.subject_edit.view.istop.label}</label>
							<label class="checkbox inline">
								<input type="radio" class="fancy" name="rdoIsTop" value="1" {if $subject['ISTOP'] == 1}checked="checked"{/if} />{lang cms.subject_edit.view.istop.yes}
							</label>
							<label class="checkbox inline">
								<input type="radio" class="fancy" name="rdoIsTop" value="0" {if $subject['ISTOP'] == 0}checked="checked"{/if} />{lang cms.subject_edit.view.istop.no}
							</label>
						</fieldset>
						
						<h5>{lang admin.validate.swfupload}({lang admin.validate.swfupload.limit}{$table[FILENUM]}{lang admin.validate.swfupload.unit})</h5>
						
						<hr/>
						<div id="divFileUploadButton" class="upload-button"><span id="spnButtonPlaceholder"></span></div>
						<div id="divFileProgressContainer" class="upload-progress"></div>
		            	<div id="divThumbnails">
			            	<table class="table" style="width:auto;">
			            		<thead>
			            			<tr>
				            			<th width="60">{lang admin.validate.swfupload.th.pic}</th>
				            			<th>{lang admin.validate.swfupload.th.name}</th>
				            			<th width="60">{lang admin.validate.swfupload.th.no}</th>
				            			<th width="80">{lang admin.validate.swfupload.th.delete}</th>
			            			</tr>
			            		</thead>
			            		<tbody id="tbl_body_column">
			            		<!--{loop $subject_files $key $image}-->
			            		<tr>
					            	<td>
					            		<input type="hidden" name="hdnImagePath[]" value="{$image[4]}" />
					            		<a href="{$image[3]}" target="_blank"><img class="image" style="width:60px; height:60px;" src="{$image[0]}" border="0" /></a>
					            	</td>
					            	<td>
					            		<span class="imageTitle">{$image[1]}<!--{if $image[5]}--><br/>[{$image[5]}px * {$image[6]}px]<!--{/if}--></span>
					            	</td>
					            	<td>
						            	<input type="text" name="txtImageDisplayOrder[]" value="{echo $key + 1;}" class="input-mini" />
					            	</td>
					            	<td>
					            		<a class="btn btn-mini btn-delete" href="javascript:void(null);" onclick="removeImage(this)">{lang admin.operation.delete}</a>
					            	</td>
					            </tr>
			            		<!--{/loop}-->
			            		<tr id="tbl_no_record"{if count($subject_files) > 0} style="display:none;"{/if}>
			            			<td colspan="4">{lang admin.validate.swfupload.empty}</td>
			            		</tr>
				            	<tr style="display:none;">
					            	<td>
					            		<input type="hidden" name="hdnImagePath[]" value="" />
					            		<img class="image" style="width:60px; height:60px;" src="" />
					            	</td>
					            	<td>
						            	<span class="imageTitle"></span>
					            	</td>
					            	<td>
						            	<input type="text" name="txtImageDisplayOrder[]" value="" class="input-mini" />
					            	</td>
					            	<td>
					            		<a class="btn btn-mini btn-delete" href="javascript:void(null);" onclick="removeImage(this)">{lang admin.operation.delete}</a>
					            	</td>
					            </tr>
					            </tbody>
					        </table>
				        </div>
				        
						<fieldset>
							<!--{if $dispatches['method'] == '_pub'}-->
							<button type="submit" class="btn btn-small btn-primary" {$dispatches[operations][add]}>{lang admin.operation.submit}</button>
							<!--{elseif $dispatches['method'] == '_update'}-->
							<button type="submit" class="btn btn-small btn-primary" {$dispatches[operations][edit]}>{lang admin.operation.submit}</button>
							<!--{/if}-->
							
							<button type="reset" class="btn btn-small">{lang admin.operation.reset}</button>
							<button type="button" class="btn btn-small" onclick="javascript:location.href='{$ADMIN_SCRIPT}/cms/subject&page={$_var[page]}&psize={$_var[psize]}{$search[querystring]}';">{lang admin.operation.go.back}</button>
						</fieldset>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript" src="editor/lang/zh_CN.js"></script>
<script type="text/javascript" src="editor/kindeditor.js"></script>

<script type="text/javascript" src="static/plugins/swfupload.js"></script>
<script type="text/javascript" src="static/plugins/swfupload_handlers.js"></script>
<script type="text/javascript" src="static/plugins/swfupload_images.js"></script>

<script>
var swfu;
var kindEditor = null;

function check_form(frm){
    if(frm.txtIdentity.value.trim().length == 0){
    	$(frm.txtIdentity).next('.help-inline').css('color', 'red');
    	frm.txtIdentity.focus();
    	return false;
    }
    
    if(frm.txtTitle.value.trim().length == 0){
    	$(frm.txtTitle).next('.help-inline').css('color', 'red');
    	frm.txtTitle.focus();
    	return false;
    }
    
    if(kindEditor.html().length == 0){
    	$(frm.txtContent).next('.help-inline').css('color', 'red');
    	kindEditor.focus();
    	return false;
    }
    
    frm.btnSubmit.disabled = true;
    
 	return true;
}

$(function(){
	$('.fancy').uniform();
	
	$('.input-time').datetimepicker({format: 'yyyy-mm-dd hh:ii', autoclose:true, todayBtn:true});
	
	$('fieldset input,textarea').blur(function(){
		$(this).next('.help-inline').css('color', '#333');
	});
	
	swfupload_params.limit = {echo $table[FILENUM];};
	swfupload_params.uploaded = {echo count($subject_files);};
	
	swfu = new SWFUpload({
		upload_url: "{$ADMIN_SCRIPT}/cms/subject/_upload&_SALT={$_var[current][SALT]}",
		
		file_size_limit : "200KB", 
		file_types : "*.jpg;*.bmp;*.gif;*.png",
		file_types_description : "JPG Images",
		file_upload_limit : "0",
		
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,
		upload_complete_handler : uploadComplete,
		
		button_image_url : "static/images/swfupload/swfupload.png",
		button_placeholder_id : "spnButtonPlaceholder",
		button_width: 120,
		button_height: 18,
		button_text : '{lang admin.validate.swfupload.lang.button}({lang admin.validate.swfupload.lang.button.size.200})',
		button_text_style : '',
		button_text_top_padding: 0,
		button_text_left_padding: 18,
		
		flash_url : "static/swfupload.swf",
		
		custom_settings : {
			upload_target : "divFileProgressContainer"
		},
		
		debug: false
	});
	
	kindEditor = KindEditor.create('#txt_content', kind_editor_onfig);
});
</script>
<!--{template /module/admin/view/foot}-->